package com.borya.filter.auth;

import java.util.Objects;

import com.borya.util.SystemConfig;

/**
 * token和sign的键
 */
public enum AppHookFlagVersion {

	KA_MENG_ANDROID("app.android.km.hookFlag.version"), XI_NIU_ANDROID(
			"app.android.xn.hookFlag.version"), YI_JIA_ANDROID(
					"app.android.yj.hookFlag.version"), QUAN_WANG_TONG_ANDROID(
							"app.android.qwt.hookFlag.version"), JU_LIAN_ANDROID("app.android.jl.hookFlag.version"),;
	private String version;

	AppHookFlagVersion(String version) {
		this.version = version;
	}

	public static boolean hasAbility(String appType, int version) {
		SystemConfig instance = SystemConfig.getInstance();
		if (Objects.equals(AppType.KA_MENG.getType(), appType)) { // 卡盟
			return version >= instance.getInteger(AppHookFlagVersion.KA_MENG_ANDROID.version);
		} else if (Objects.equals(AppType.XI_NIU.getType(), appType)) { // 喜牛
			return version >= instance.getInteger(AppHookFlagVersion.XI_NIU_ANDROID.version);
		} else if (Objects.equals(AppType.YI_JIA.getType(), appType)) { // 亿嘉
			return version >= instance.getInteger(AppHookFlagVersion.YI_JIA_ANDROID.version);
		} else if (Objects.equals(AppType.QUAN_WANG_TONG.getType(), appType)) { // 全通
			return version >= instance.getInteger(AppHookFlagVersion.QUAN_WANG_TONG_ANDROID.version);
		} else if (Objects.equals(AppType.JU_LIAN.getType(), appType)) { // 聚联
			return version >= instance.getInteger(AppHookFlagVersion.JU_LIAN_ANDROID.version);
		} else if (Objects.equals(AppType.KM_SDK.getType(), appType)) {
			return true;
		}
		return false;
	}

}
